<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Login</title>

        <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="assets/css/font-awesome.min.css" />

        <link rel="stylesheet" href="assets/css/ace.min.css" />
        <link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
        <link rel="stylesheet" href="assets/js/plugin/code/code.css" />
        <!--[if lte IE 8]>
          <link rel="stylesheet" href="../assets/css/ace-ie.min.css" />
        <![endif]-->

        <!--[if lt IE 9]>
        <script src="../assets/js/html5shiv.js"></script>
        <script src="../assets/js/respond.min.js"></script>
        <![endif]-->
        <style>
            @font-face { 
                font-family: "Open Sans"; /*这里是说明调用来的字体名字*/ 
                src: url('assets/font/OpenSans-Regular.ttf'); /*这里是字体文件路径*/ 
            } 
            .login-layout .widget-box {
                background-color: rgba(235, 235, 235, 0.5);
            }
        </style>
    </head>

    <body class="login-layout" style="background:url(assets/images/bg2.jpg) center;">
        <div class="main-container">
            <div class="main-content">
                <div class="row">
                    <div class="col-sm-10 col-sm-offset-1">
                        <div class="login-container">
                            <div class="center">
                                <!--                                <h1>
                                                                    <span class="white">上海理想省DPI汇聚分析平台 v1.0</span>
                                                                </h1>-->
                                <h3 class="white">
                                   <!--           <img src="assets/images/ideal_logo.png" style="height:40px;" />-->
                                    省DPI汇聚分析平台v1.0
                                </h3> 
                            </div>
                            <div class="space-6"></div>
                            <div class="position-relative">
                                <div id="login-box" class="login-box visible widget-box no-border">
                                    <div class="widget-body">
                                        <div class="widget-main">
                                            <h4 class="header blue lighter bigger">
                                                <i class="icon-coffee green"></i>
                                                管理员登录
                                            </h4>
                                            <div class="space-6"></div>
                                            <form id="form">
                                                <fieldset>
                                                    <label class="block clearfix">
                                                        <span class="block input-icon input-icon-right">
                                                            <input type="text" value="" id="UserName" name="UserName" class="form-control" placeholder="用户名" required/>
                                                            <i class="icon-user"></i>
                                                        </span>
                                                    </label>
                                                    <label class="block clearfix">
                                                        <span class="block input-icon input-icon-right">
                                                            <input type="password" value="" id="Password" name="Password" class="form-control" placeholder="密码" required/>
                                                            <i class="icon-lock"></i>
                                                        </span>
                                                    </label>
                                                    <div class="space"></div>
                                                    <p><span id="idcode"></span></p>
                                                    <div class="clearfix">
                                                        <button type="submit" id="login-btn" class="width-35 pull-right btn btn-sm btn-primary">
                                                            <i class="icon-key"></i>
                                                            登录
                                                        </button>
                                                    </div>

                                                    <div class="space-4"></div>
                                                </fieldset>
                                            </form>
                                        </div><!-- /widget-main -->
                                    </div><!-- /widget-body -->
                                </div><!-- /login-box -->
                            </div><!-- /position-relative -->
                        </div>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div>
        </div><!-- /.main-container -->

        <!-- basic scripts -->

        <script src="assets/js/jquery.js"></script>
        <script src="assets/js/jquery.validate.js"></script>
        <script src="assets/js/jquery.validate-util.js"></script>
        <script src="assets/js/plugin/code/code.js"></script>
        <script src="assets/js/Base64.js"></script>
        <script type="text/javascript">
            jQuery(function($) {
                $.idcode.setCode();
                $("#form").validate({
                    submitHandler: function() {
                        var username = $("#UserName").val().trim();
                        var pwd = $("#Password").val().trim();
//                    console.log(username+'+'+pwd);
                        if (!$.idcode.validateCode()) {
                            alert("请输入正确的验证码！");
                        } else {
                            if (username == "" || pwd == "") {
                                alert("请输入用户名和密码不能为空！");
                            } else {
                                var obj = {
                                    username: username,
                                    password: pwd
                                }
                                $.post("/action/user/login.do", {json: JSON.stringify(obj)}, function(data) {
                                    switch (data.result) {
                                        case "1":
                                            alert("密码错误！")
                                            break;
                                        case "2":
                                            alert("此用户已登录！")
                                            break;
                                        case "3":
                                            alert("登录异常！")
                                            break;
                                        case "4":
                                            alert("用户不存在！")
                                            break;
                                        case "5":
//                                            alert("登录成功！");
                                            window.location.href = 'index.jsp';
                                            break;
                                        default:
                                            "n 与 case 1 和 case 2 不同时执行的代码"
                                    }
                                }, 'json')
                            }

                        }
                    }
                });
            });
        </script>

    </body>
</html>
